home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Amos / AMOSList-0198 / AMOSLIST / text0173.txt < prev    next >
Encoding:
Text File  |  1998-06-24  |  10.9 KB  |  336 lines

  1. It was on the night of 31-Jan-98, when no creatures were stirring, and all was
  2. silent. Suddenly, Martin jumped out from behind a rock and wouldnt stop
  3. shouting about "Arexx calls from amos" until I was forced to knock them out:
  4. »-> Hi guys.
  5.  
  6. »-> Can anyone of you tell me if there exists a arexx extension for amos.
  7.  
  8. Not that I know of, one isnt needed  =)
  9.  
  10. »-> I would like to be able to send a command directly to yam.
  11.  
  12. »-> Something like this would be nice:
  13.  
  14. »-> Arexx address="YAM"
  15. »-> Arexx send "getmail"
  16.  
  17. »-> Does this extension exists?, and where to get it?
  18.  
  19. »-> I know i'm able to use the exec command like exec "RX Script.arexx".
  20. »-> But that's another problem i'm having, it's not stable enough.
  21. »-> Some times the script works perfectly, other times it just executes
  22. »-> the first three or four lines. and then hangs. Have anyone else had this
  23. »-> problem, and how do i avoid it?.
  24.  
  25. OK, take a look at this program that allows AMOS to interact with AmIRC. At
  26. the bottom is also the small AREXX script, mish.amirx, which goes in AmIRC and
  27. all channel text is sent to it:
  28.  
  29. Rem ******************************************************************** 
  30. Rem **    NIALL  Non-Intelligent AMOS Language Learner Version 1.0    ** 
  31. Rem **   ==========================================================   ** 
  32. Rem **                Written By Matthew Peck in 1990                 **      
  33.     
  34. Rem ******************************************************************** 
  35. Set Buffer 400
  36. MNW=3000
  37. Randomize Timer
  38. Hide On : Close Editor 
  39. Close Workbench 
  40. Dim WORD$(MNW,1),W$(255),CO(1)
  41. Global COM,T$,WORD$(),NUM,W$(),W,SPEAK,HARD,CO(),MNW
  42. WORD$(0,0)=" " : WORD$(MNW,0)="."
  43. SETUP
  44. Do 
  45.    USER_INPUT
  46.    If COM=1 Then Goto SKIPIT
  47.    NIALL_REPLIES
  48.    SKIPIT:
  49. Loop 
  50. Rem -------------------------------------------------------------------- 
  51. Procedure SEE_INSTRUCTIONS
  52.    Screen Hide 1 : Screen Hide 0
  53.    For F=1 To 2 : Unpack 2 To 2 : Gr Writing 0
  54.       For G=1 To 25 : Read C,A$ : Ink 0 : Text 17,33+G*8,A$
  55.          Ink C : Text 16,32+G*8,A$
  56.    Next G : Wait Key : Fade 2 : Wait 30 : Next F
  57.    Screen Close 2
  58.    Screen Show 1 : Screen Show 0
  59.    Data 6,"                               COMMAND WORDS"
  60.    Data 1," "
  61.    Data 1," When you are given the prompt USER: you will normally type in  a 
  62. sentence,"
  63.    Data 1,"but you can also type in a command word.    All command words  are 
  64. prefixed"
  65.    Data 1,"by a '#'.  This version (1.0) can support the following commands."
  66.    Data 1," "
  67.    Data 7,"#LIST        Displays Nialls current dictionary on the screen."
  68.    Data 1," "
  69.    Data 7,"#LLIST       Outputs the dictionary to a printer."
  70.    Data 1," "
  71.    Data 7,"#LPRINT      Toggles direct output to printer."
  72.    Data 1," "
  73.    Data 7,"#SPEAK       Toggles speech."
  74.    Data 1," "
  75.    Data 7,"#SAVE        Saves the current dictionary to disc under any name."
  76.    Data 1," "
  77.    Data 7,"#LOAD        Loads a previously saved dictionary from disc."
  78.    Data 1," "
  79.    Data 7,"#CORRECT     Corrects a mispelt word in the dictionary."
  80.    Data 1," "
  81.    Data 7,"#FRESH       Clears the current dictionary."
  82.    Data 1," "
  83.    Data 7,"#QUIT        Leaves the program."
  84.    Data 1," "
  85.    Data 5,"                                PRESS A KEY"
  86.    Data 5,"                                  CREDITS"
  87.    Data 1," "
  88.    Data 4,"         Written by Matthew Peck in AMOS Version 1.1 in August
  89. 1990"
  90.    Data 1,"  The original idea for NIALL was adapted from a program called
  91. DANI, which"
  92.    Data 1,"was written for the MSX machines and published in a magazine,MSX
  93. Computing."
  94.    Data 1,"NIALL is a complete re-write but I would like to give credit to the
  95.  author"
  96.    Data 1,"of DANI for the inspiration.  However, I no longer have the
  97. magazine and do"
  98.    Data 1,"not know the author's name. If you wrote DANI then contact me so
  99. that I can"
  100.    Data 1,"place your name in the credit list."
  101.    Data 1," "
  102.    Data 1,"  Many thanks go to the following people for their help,
  103. suggestions etc."
  104.    Data 6,"Adam Wright................................For waiting for me to
  105. code this."
  106.    Data 6,"Pat Fox and Julian Brown.....For playtesting my BBC basic version
  107. to death."
  108.    Data 6,"Kevin Tye...................................For being a generally
  109. nice guy."
  110.    Data 6,"Gary Keogh...............For being a great room-mate and friend at
  111. college."
  112.    Data 6,"Francios Lionet........................For AMOS, what else, and
  113. finally to "
  114.    Data 6,"Sarah Gould...........For being such a caring and understanding
  115. girlfriend."
  116.    Data 1," "
  117.    Data 1,"My address is:"
  118.    Data 4,"      23 Welbeck Avenue, Bedgrove, Aylesbury, Bucks, ENGLAND, HP21
  119. 9BH."
  120.    Data 1," Contact me with/for ideas, programs, NIALL dictionaries and NIALL
  121. updates."
  122.    Data 1," "
  123.    Data 5,"                                PRESS A KEY"
  124.    Data 1," "
  125.    Data 5,"                        AMOS (c) 1990 Mandarin/Jawx"
  126. End Proc
  127. Procedure USER_INPUT
  128.    COM=0 : For F=1 To 3 : Print : Next F : For F=1 To 3 : Cup : Next F
  129.    Pen CO(1) : Print "USER:"; : Pen 1 : Line Input " ";T$
  130.    Cup : Pen CO(1) : Print "USER: "; : Pen 1 : Print T$
  131.    If HARD=1 Then Lprint " USER:";T$
  132.    If T$="" Then Pop Proc
  133.    T$=Lower$(T$)
  134.    Rem --- Is it a command string --- 
  135.    If Left$(T$,1)="#" Then COMMANDS : COM=1 : Pop Proc
  136.    Rem --- Cuts out the rubbish --- 
  137.    R$="" : For F=1 To Len(T$)
  138.       If Mid$(T$,F,1)="," Then Mid$(T$,F,1)="."
  139.       If Instr("!£$%^&*()_+|}{@?></#\="+Chr$(34),Mid$(T$,F,1))=0 Then
  140. R$=R$+Mid$(T$,F,1)
  141.    Next F : T$=R$
  142.    Rem --- Seperates into words --- 
  143.    If Right$(T$,1)="." Then Right$(T$,1)=" "
  144.    Q$=T$
  145.    FULLSTOP:
  146.    If Instr(Q$,".")<>0 Then FS=1 : T$=Left$(Q$,Instr(Q$,".")-1) :
  147. Q$=Right$(Q$,Len(Q$)-Instr(Q$,"."))
  148.    W=1 : W$(W)="" : For F=1 To Len(T$)
  149.       If Mid$(T$,F,1)=" " Then If Mid$(T$,F+1,1)<>" " Then W=W+1 : W$(W)="" :
  150. Goto SKIP
  151.       W$(W)=W$(W)+Mid$(T$,F,1)
  152.    SKIP: Next F
  153.    If NUM<>MNW-1
  154.       ANALYSE_SENTENCE
  155.    End If 
  156.    If FS=1 Then FS=0 : T$=Q$ : Goto FULLSTOP
  157. End Proc
  158. Procedure ANALYSE_SENTENCE
  159.    Rem --- Loop for the number of words +1 ---
  160.    OLD=0
  161.    For H=1 To W+1
  162.       If H=W+1 Then F=MNW : Goto FOUNDIT
  163.       For F=1 To NUM : If W$(H)=WORD$(F,0) Then Goto FOUNDIT
  164.       Next F
  165.       Rem --- The word is a new one ---
  166.       NUM=NUM+1 : WORD$(NUM,0)=W$(H) : F=NUM
  167.       FOUNDIT:
  168.       If WORD$(OLD,1)="" Then WORD$(OLD,1)="1|"+Str$(F)+"(1)" : Goto ALLDONE
  169.       C$=WORD$(OLD,1) : C$=Str$(Val(C$)+1)+Right$(C$,Len(C$)-Instr(C$,"|")+1)
  170.       For G=Instr(C$,"|")+1 To Len(C$)
  171.          If Val(Right$(C$,Len(C$)-G))=F Then Goto HERE
  172.          G=Instr(C$,")",G)
  173.       Next G
  174.       C$=C$+Str$(F)+"(1)" : WORD$(OLD,1)=C$ : Goto ALLDONE
  175.       HERE:
  176.       G=Instr(C$,"(",G) : I=Instr(C$,")",G)-1
  177.       C$=Left$(C$,G)+Str$(Val(Right$(C$,Len(C$)-G))+1)+Right$(C$,Len(C$)-I)
  178.       WORD$(OLD,1)=C$
  179.       ALLDONE:
  180.       OLD=F
  181.    Next H
  182. End Proc
  183. Procedure NIALL_REPLIES
  184.    If NUM=0 Then Pen CO(1) : Print "I cannot speak yet!" : Pen 1 : Pop Proc
  185.    REP$="" : C=0
  186.    RLOOP:
  187.    C$=WORD$(C,1) : R=Rnd(Val(C$)) : If R=0 Then Goto RLOOP
  188.    For G=Instr(C$,"(") To Len(C$)
  189.       R=R-Val(Right$(C$,Len(C$)-G)) : If R<=0 Then Goto THISWORD
  190.       G=Instr(C$,"(",G+1)-1
  191.    Next G
  192.    End 
  193.    THISWORD:
  194.    For F=G To 1 Step -1
  195.       F$=Mid$(C$,F,1) : If(F$=")") or(F$="|") Then Goto WORD
  196.    Next F
  197.    WORD:
  198.    D=Val(Right$(C$,Len(C$)-F))
  199.    REP$=REP$+WORD$(C,0)+" "
  200.    C=D : If C<>MNW Then Goto RLOOP
  201.    Do 
  202.       If Left$(REP$,1)<>" " Then Exit 
  203.       REP$=Right$(REP$,Len(REP$)-1)
  204.    Loop 
  205.    If REP$="" Then Pop Proc
  206.    Left$(REP$,1)=Chr$(Asc(Left$(REP$,1))-32)
  207.    Right$(REP$,1)="."
  208.    Pen CO(1) : Print "NIALL:"; : Pen 1 : Print REP$
  209.    If SPEAK=1 Then Say REP$,0
  210.    If HARD=1 Then Lprint "NIALL:";REP$
  211. End Proc
  212. Procedure SETUP
  213.    If Fast Free<>0
  214.       Unpack 1 To 0 : Screen Display 0,128,40,320,28
  215.    End If 
  216.    If Fast Free<>0
  217.       Screen Open 1,640,230,4,Hires : CO(0)=2 : CO(1)=3
  218.    Else 
  219.       Screen Open 1,320,230,2,Lowres : CO(0)=1 : CO(1)=1
  220.    End If 
  221.    Screen Display 1,128,70,, : Flash Off : Screen 1 : Palette $0,$FFF,$F00,$48
  222.    Pen CO(0) : Paper 0 : Cls 
  223.    Centre "Welcome to NIALL" : Print 
  224.    Centre "Non Intelligent AMOS Language Learner" : Print 
  225.    Centre "Written in AMOS Basic Version 1.1" : Print 
  226.    Centre "by Matthew Peck in 1990" : Print : Print 
  227.    Centre "This program is fully Public Domain" : Print : Print 
  228.    If Fast Free<>0
  229.       Centre "Would you like further instructions (Y/N)" : A$=Input$(1) :
  230. Print 
  231.       A$=Upper$(A$)
  232.       If A$="Y"
  233.          SEE_INSTRUCTIONS
  234.       End If 
  235.       Centre ".......... Get Typing ..........."
  236.    End If 
  237.    Print 
  238. End Proc
  239. Procedure COMMANDS
  240.    If T$="#list"
  241.       For F=0 To NUM Step 20
  242.          For G=0 To 19 : If F+G<=NUM
  243.                Print F+G,WORD$(F+G,0),WORD$(F+G,1)
  244.             End If 
  245.          Next G : Print : Pen CO(0) : Centre "PRESS A KEY" : Pen 1 : Print :
  246. Wait Key 
  247.       Next F : Pop Proc
  248.    End If 
  249.    If T$="#llist"
  250.       For F=0 To NUM : Lprint F,WORD$(F,0),WORD$(F,1) : Next F
  251.    End If 
  252.    If T$="#save"
  253.       Show On : A$=Fsel$("*.NIALL") : Hide On 
  254.       If Upper$(Right$(A$,6))<>".NIALL"
  255.          A$=A$+".NIALL"
  256.       End If 
  257.       Open Out 1,A$ : Print #1,NUM
  258.       For F=0 To NUM : Print #1,WORD$(F,0) : Print #1,WORD$(F,1) : Next F
  259.       Close 1
  260.    End If 
  261.    If T$="#load"
  262.       Show On : A$=Fsel$("*.NIALL") : Hide On : Open In 1,A$
  263.       Input #1,NUM
  264.       Y=Y Curs
  265.       For F=0 To NUM : Locate 0,Y : Print "Countdown:";NUM-F;"  "; : Input
  266. #1,WORD$(F,0) : Input #1,WORD$(F,1) : Next F
  267.       Close 1
  268.       Print 
  269.    End If 
  270.    If T$="#correct"
  271.       Pen CO(0) : Print "Enter incorrect word:"; : Pen 1 : Input " ";O$
  272.       For F=1 To NUM
  273.          If Lower$(O$)=WORD$(F,0)
  274.             Pen CO(0) : Print "Enter correct spelling:"; : Pen 1 : Input "
  275. ";N$
  276.             WORD$(F,0)=Lower$(N$)
  277.          Else 
  278.          Next F : Print "Cannot find word ";O$
  279.       End If 
  280.    End If 
  281.    If T$="#fresh"
  282.       Pen CO(0) : Centre "Are you sure (Y/N)" : A$=Input$(1) : Print 
  283.       If Upper$(A$)="Y"
  284.          For F=0 To NUM : WORD$(F,0)="" : WORD$(F,1)="" : Next F : NUM=0
  285.       End If 
  286.    End If 
  287.    If T$="#quit"
  288.       Pen CO(0) : Centre "Do you really want to quit (Y/N)" : A$=Input$(1) :
  289. Print 
  290.       If Upper$(A$)="Y"
  291.          Screen Close 0 : Screen Close 1 : End 
  292.       End If 
  293.    End If 
  294.    If T$="#speak"
  295.       If SPEAK=0
  296.          SPEAK=1
  297.       Else 
  298.          SPEAK=0
  299.       End If 
  300.    End If 
  301.    If T$="#lprint"
  302.       If HARD=0
  303.          HARD=1
  304.       Else 
  305.          HARD=0
  306.       End If 
  307.    End If 
  308. End Proc
  309.  
  310. And now for the AREXX script (mish.amirx):
  311.  
  312. /**************************************************************************/
  313. /*    Script to parse stuff from AmIRC to AMOS                            */
  314. /**************************************************************************/
  315.  
  316. parse arg args
  317. options results
  318.  
  319. address AMOS args
  320.  
  321. EXIT 10
  322.  
  323. -- 
  324. Andrew "Mushroom" Kellett
  325. --
  326.  Email: Andy Kellett <mushypd@redrose.net>  Team *AMOS* + IAPA Team *AMIGA*
  327.   alt.religion.amos - AMOS now on usenet! AMOS Mailinglist also mirrored
  328.  
  329.      World's Largest AMOS Homepages - http://www.mushy-pd.demon.co.uk
  330.                Official F1 Software Distributor for the USA
  331.  
  332.          Massive FTP site with AMOS/C64 and Mods/Samples + more at
  333.                             mushy-pd.dyn.ml.org
  334.  
  335.  
  336.